package com.bankcomm.ui;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView.OnEditorActionListener;

import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.CoordinateConvert;
import com.baidu.mapapi.GeoPoint;
import com.baidu.mapapi.ItemizedOverlay;
import com.baidu.mapapi.MKAddrInfo;
import com.baidu.mapapi.MKBusLineResult;
import com.baidu.mapapi.MKDrivingRouteResult;
import com.baidu.mapapi.MKPlanNode;
import com.baidu.mapapi.MKPoiResult;
import com.baidu.mapapi.MKSearch;
import com.baidu.mapapi.MKSearchListener;
import com.baidu.mapapi.MKSuggestionResult;
import com.baidu.mapapi.MKTransitRouteResult;
import com.baidu.mapapi.MKWalkingRouteResult;
import com.baidu.mapapi.MapController;
import com.baidu.mapapi.MapView;
import com.baidu.mapapi.Overlay;
import com.baidu.mapapi.OverlayItem;
import com.baidu.mapapi.RouteOverlay;
import com.baidu.mapapi.TransitOverlay;
import com.bankcomm.BankcommApplication;
import com.bankcomm.R;
import com.bankcomm.bean.AroundShopListObj;
import com.bankcomm.bean.AroundShopObj;
import com.bankcomm.bean.PageInfo;
import com.bankcomm.common.ConfigManager;
import com.bankcomm.common.LPMid;
import com.bankcomm.common.Rotate3d;
import com.bankcomm.location.BaiduLocation;
import com.bankcomm.location.MyLocationOverlayItem;
import com.bankcomm.location.MyPoiOverlayItem;
import com.bankcomm.ui.adapter.AroundShopListAdapter;
import com.bankcomm.ui.adapter.ArrayWheelAdapter;
import com.bankcomm.ui.adapter.DistenceAdaper;
import com.bankcomm.ui.specialwidget.DistanceAndDistPicker;
import com.bankcomm.ui.specialwidget.MostPopShopGallery;
import com.bankcomm.ui.specialwidget.MostPopShopTypePicker;
import com.bankcomm.ui.specialwidget.MyBoderGridView;
import com.bankcomm.ui.specialwidget.MyIXListView;
import com.bankcomm.ui.specialwidget.OnWheelChangedListener;
import com.bankcomm.ui.specialwidget.WheelView;
import com.bankcomm.ui.specialwidget.MyIXListView.IXListViewListener;
import com.bankcomm.ui.views.LPBottomBar;
import com.bankcomm.util.DensityUtil;
import com.bankcomm.util.LPUtils;
import com.rytong.tools.datastorage.PackageManagerAndroid;
import com.rytong.tools.httpconnect.WaitDialog;
import com.rytong.tools.httpconnect.WaitDialog.Task;
import com.rytong.tools.utils.EventHandler;
import com.rytong.tools.utils.LPToastUtil;
import com.rytong.tools.utils.Utils;

public class BOC_SpecialShop_main_Activity extends BOCMyMapViewActivity
		implements android.view.View.OnClickListener, IXListViewListener {
	private LinearLayout mainLayout;
	private LinearLayout layoutFirstSearch;
	/** 选城市 **/
	private TextView tvChooseCity;
	/** 所有商圈 **/
	private TextView tvSelectAllShop;
	/** 所有行业 **/
	private TextView tvSelectAllShopType;
	/** 搜索名称 **/
	private EditText etSearchName;
	private View wheelView;
	protected int aroundSmallItem;
	protected int merchantTypeSmallItem;
	protected String type;
	private int width;
	public PopupWindow aroundPW;
	private LPMid mid;
	private int merchantTypeBigItem;
	/** 特惠商户列表页面 **/
	private LinearLayout layoutMostPopShopList;
	private TextView aroundShopActTypeText;
	private LinearLayout aroundShopRegionLinear;
	public TextView aroundShopRangeText;
	private LinearLayout aroundShopRangeLinear;
	private TextView aroundShopTypeText;
	private ImageView shopSearchList;
	private ImageView shopSearchMap;
	private MyIXListView aroundShopLV;
	private Dialog locationDialog;
	private Dialog getAroundShopPD;
	protected AroundShopObj aroundShopDataObj;
	private Handler ixHandler;
	private String typeNameShow = "";

	protected static int merchantRegionSmallItem = 0;

	/** 城市大类、小类 */
	private int aroundShopCityBigItem = 10000;
	private int aroundShopCitySmallItem;
	/** 类别大类、小类 */
	private int aroundShopTypeBigItem;
	private int aroundShopTypeSmallItem;

	/** 滚轮常量值 */
	/** 滚轮常量值 */
	public int wheelConstant = 0;
	public static final int AROUND_SHOP_CITY = 1;
	public static final int AROUND_SHOP_RANGE = 2;
	public static final int AROUND_SHOP_TYPE = 3;

	/** 临时存储城市、商圈、范围、类别 */
	private String aroundShopCity_S = "";
	public String aroundShopDist_S = "";
	public String aroundShopRange_S = "";
	private String aroundShopType_S = "";

	private double currentLat = 0D;
	private double currentLon = 0D;

	/** 地圖中心經緯度 */
	private double centerLat = 0D;
	private double centerLon = 0D;

	/** 特惠商户列表适配器 */
	private AroundShopListAdapter aroundShopListAdapter;

	/** 范围, 默认为1 */
	private int aroundShopRangeItem = 1;
	public EditText shopSearchText;
	private TextView noResIV;
	private Dialog pickerDialog;
	private int height;
	private MostPopShopTypePicker line;
	MapView mMapView;
	private MapController mapController;
	private OverItemT myGeoOverlayItem;
	private MyPoiOverlayItem tempGeoOverlayItem;
	private BankcommApplication app;
	private Drawable myMarker;
	private Drawable poiMarker;
	View mPopView;
	private FrameLayout frameList;
	private DistanceAndDistPicker distancePicker;
	private LinearLayout aroundShopTypeLinear;
	/** 默认范围 */
	private static final String DEFAULTRANGE = "1000";

	boolean needGetLocation = false;
	/** 页面栈集合 */
	private HashMap<String, Stack<PageInfo>> pageInfos = new HashMap<String, Stack<PageInfo>>();
	private GridView typeGrid;

	public String[] typename = null;
	public int[] typeImageId = { R.drawable.sp_cy, R.drawable.sp_ktv,
			R.drawable.sp_dy, R.drawable.sp_market, R.drawable.sp_jyz,
			R.drawable.sp_4s, R.drawable.sp_slv, R.drawable.sp_bh,
			R.drawable.sp_more };
	public String[] typeValues = { "5462", "79320001", "79320007", "53110003",
			"55410001", "55410003", "7011", "6001", "" };
	private float padLeft;

	public static String MER_CITY_NAME = "city_name";
	public static String MER_DIST_NAME = "dist_name";
	public static String MER_TYPE_NAME = "type_name";

	public static String MER_CITY_VALUE = "city_value";
	public static String MER_DIST_VALUE = "dist_value";
	public static String MER_TYPE_VALUE = "type_value";

	public static String MER_CURRENT_BIGCITY_INDEX = "bigcityindex";

	public double lat;
	public double lon;

	public int currentID;
	public ArrayList<String> mMerchantIDList = new ArrayList<String>();
	public ArrayList<HashMap<String, Double>> pointList = new ArrayList<HashMap<String, Double>>();
	/** 搜索服务 */
	private MKSearch mSearch = null;
	private BaiduLocation locationServices;
	private Button backBtn;
	private Button homeBtn;

	/** 路线常量值 */
	public static final int WAY_DRIVING = 1;
	public static final int WAY_TRANSIT = 2;
	public static final int WAY_WALKING = 3;
	public boolean isNotShowDistChoose = false;

	/** 保存最后一次选择大类的索引值 **/
	protected int currentBigIndex = 0;
	/** 保存定位拿到的城市信息 **/
	private String currentCity = "";

	private LinearLayout dropDownList;

	private String[] arrayTypeName;
	private String[] arrayTypeValue;

	public String mark_Type = "";
	private LPBottomBar bottomLayout;

	public String search_name = "";
	private RelativeLayout topLayout;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		typename = getResources().getStringArray(R.array.red_shop_type_arr);
		// 下拉显示
		arrayTypeName = getResources().getStringArray(R.array.all_type_arr);
		// 下拉值
		arrayTypeValue = getResources().getStringArray(
				R.array.all_type_value_arr);
		BankcommApplication.getInstance().addActivity(this);
		pageInfos.put("specialShop", new Stack<PageInfo>());
		clearPageStack();
		mid = LPMid.getInstance();
		ixHandler = new Handler();
		WindowManager window = this.getWindowManager();
		width = window.getDefaultDisplay().getWidth();
		height = window.getDefaultDisplay().getHeight();
		setContentView(R.layout.specialshop_main_layout);
		bottomLayout = (LPBottomBar) findViewById(R.id.bottom_bar);
		bottomLayout.setSelectTab(1);
		topLayout = (RelativeLayout) findViewById(R.id.linearLayout1);

		mainLayout = (LinearLayout) findViewById(R.id.content_shop);
		line = new MostPopShopTypePicker(this, mid.bigMostPopClass,
				mid.smallMostPopClass);
		backBtn = (Button) findViewById(R.id.backtitle);
		homeBtn = (Button) findViewById(R.id.hometitle);

		backBtn.setOnClickListener(this);
		homeBtn.setOnClickListener(this);

		initTopAndBottomHeight();
		initProgressDialog();
		initMostPopShopList();
		instanceFirstSearchView();
		mainLayout.addView(layoutFirstSearch);
		pushPageToStack(layoutFirstSearch, "specialShop");
		handleJarEvent();
		locationServices = BaiduLocation.getInstance();
	}

	private void initTopAndBottomHeight() {
		LPUtils.scaledTHeightRel(topLayout);
		LPUtils.setTitleButtonWH(backBtn);
		LPUtils.setTitleButtonWH(homeBtn);
		// LPUtils.scaledTHeight(bottomLayout);
	}

	private void handleJarEvent() {
		EventHandler uhandler = new EventHandler();
		uhandler.eventHandler = new Handler() {
			public void handleMessage(Message msg) {

				if (null != msg && msg.what == EventHandler.MSG_AROUND_SEARCH) {
					Bundle bundle = msg.getData();
					int bigItem = bundle.getInt("bigType");
					int smallItem = bundle.getInt("smallType");
					aroundShopTypeBigItem = bigItem;
					aroundShopTypeSmallItem = smallItem;
					HashMap<Integer, String> bigMap = mid.bigMostPopMap;
					HashMap<Integer, HashMap<Integer, String>> smallMap = mid.smallMostPopMap;
					String bigClass[] = mid.bigMostPopClass;
					String smallClass[][] = mid.smallMostPopClass;

					String bigNameClass[] = mid.bigMostPopClass;
					String smallNameClass[][] = mid.smallMostPopClass;

					String aroundShopType_t = "";
					if (bigMap.get(bigItem) != null) {
						aroundShopType_t = bigMap.get(bigItem);
					} else {
						aroundShopType_t = smallMap.get(bigItem).get(smallItem);
					}

					// 显示文本
					String aroundShopTypeTextVal = "";
					if (bigMap.get(bigItem) != null) {
						aroundShopTypeTextVal = bigNameClass[bigItem];
					} else {
						// 改成只显示小类, 若是所有则显示大类.
						if ("所有".equals(smallNameClass[bigItem][smallItem])) {
							aroundShopTypeTextVal = bigNameClass[bigItem];
						} else {
							aroundShopTypeTextVal = smallNameClass[bigItem][smallItem];
						}
					}

					Utils.printOutToConsole(aroundShopTypeTextVal);
					aroundShopTypeText.setText(aroundShopTypeTextVal);
					// 存储类型
					aroundShopType_S = aroundShopType_t;
					typeNameShow = aroundShopTypeTextVal;
					String urlBody_t = "";
					if (mid.isSB) {
						// 若未保存范围值时
						if (aroundShopRange_S == null
								|| aroundShopRange_S.length() == 0) {
							aroundShopRange_S = DEFAULTRANGE;
						}
						urlBody_t = "page=1&radius="
								+ Utils.escapeURIComponent(aroundShopRange_S)
								+ "&longitude=" + String.valueOf(currentLon)
								+ "&latitude=" + String.valueOf(currentLat)
								+ "&type="
								+ Utils.escapeURIComponent(aroundShopType_t)
								+ "&name="
								+ Utils.escapeURIComponent(search_name)
								+ "&mark_type="
								+ Utils.escapeURIComponent(mark_Type);
					} else {
						urlBody_t = "page=1&city="
								+ Utils.escapeURIComponent(aroundShopCity_S)
								+ "&dist="
								+ Utils.escapeURIComponent(aroundShopDist_S)
								+ "&type="
								+ Utils.escapeURIComponent(aroundShopType_t)
								+ "&name="
								+ Utils.escapeURIComponent(search_name)
								+ "&mark_type="
								+ Utils.escapeURIComponent(mark_Type);
					}

					getAroundShopData(true, urlBody_t, "");
					if (layoutFirstSearch.getParent() != null) {
						mainLayout.removeView(layoutFirstSearch);
						if (layoutMostPopShopList.getParent() != null) {
							layoutMostPopShopList.setVisibility(View.VISIBLE);
						} else {
							mainLayout.addView(layoutMostPopShopList);
						}
						pushPageToStack(layoutMostPopShopList, "specialShop");
					}
					if (aroundPW.isShowing()) {
						aroundPW.dismiss();
					}
				}
			}
		};
	}

	private void initProgressDialog() {
		locationDialog = mid.creatDialog(locationDialog,
				getString(R.string.location_explain), this);
		locationDialog.setCanceledOnTouchOutside(false);

		getAroundShopPD = mid.creatDialog(getAroundShopPD,
				getString(R.string.onLoading), this);
		getAroundShopPD.setCanceledOnTouchOutside(false);
	}

	/**
	 * 根据各种参数定位并查找数据
	 * 
	 * @param isFirst
	 *            是否首次请求列表数据
	 * @param textVal
	 *            滚轮搜索文本值
	 */
	public void locationAndQueryData(final boolean isFirst, final String textVal) {
		runOnUiThread(new Runnable() {
			public void run() {
				locationServices.getLocation(
						BOC_SpecialShop_main_Activity.this, new Handler() {
							@Override
							public void handleMessage(Message msg) {
								switch (msg.what) {
								case 1001:
									if (locationDialog != null
											&& !locationDialog.isShowing())
										locationDialog.show();
									break;
								case 2001:
									locationDialog.dismiss();
									Bundle bundle = msg.getData();
									if (bundle != null) {
										mid.currentLon = bundle
												.getDouble("lon");
										mid.currentLat = bundle
												.getDouble("lat");

										currentCity = bundle.getString("city");
										// currentCity = "上海";
										if (!currentCity.equals("")
												|| currentCity != null) {
											String noCity = "";

											for (int i = 0; i < mid.bigCityClass.length; i++) {
												String cityName = mid.bigCityClass[i];

												if (currentCity
														.equals(cityName)) {
													currentBigIndex = i;
													noCity = "true";
													String selectCity = tvChooseCity
															.getText()
															.toString();

													if (!cityName
															.equals(selectCity)) {
														try {
															if (layoutFirstSearch
																	.getVisibility() == View.VISIBLE) {
																showMakeSureChooseCity(
																		selectCity,
																		cityName);
															}
														} catch (Exception e) {
														}
														return;
													}
													break;
												}
											}
											if (noCity.equals("")) {
												LPToastUtil
														.getInstance()
														.getToast(
																"对不起,您所在的城市暂无最红商户!",
																BOC_SpecialShop_main_Activity.this);
												return;
											}
										} else {
											return;
										}
										//
										currentLat = mid.currentLat;
										currentLon = mid.currentLon;

										getAroundShopData(isFirst, getUrlBody(
												true, aroundShopType_S), "");
									}
									break;
								case 3001:
									locationDialog.dismiss();

									mid.currentLon = ConfigManager.default_current_lon;
									mid.currentLat = ConfigManager.default_current_lat;

									currentCity = "上海";
									if (!currentCity.equals("")
											|| currentCity != null) {
										String noCity = "";

										for (int i = 0; i < mid.bigCityClass.length; i++) {
											String cityName = mid.bigCityClass[i];

											if (currentCity.equals(cityName)) {
												currentBigIndex = i;
												noCity = "true";
												String selectCity = tvChooseCity
														.getText().toString();

												if (!cityName
														.equals(selectCity)
														&& !selectCity
																.equals("选择城市")) {
													showMakeSureChooseCity(
															selectCity,
															cityName);
													return;
												}
												break;
											}
										}
										if (noCity.equals("")) {
											LPToastUtil
													.getInstance()
													.getToast(
															" 对不起,您所在的城市暂无最红商户!",
															BOC_SpecialShop_main_Activity.this);
											return;
										}
									} else {
										return;
									}
									currentLat = ConfigManager.default_current_lat;
									currentLon = ConfigManager.default_current_lon;
									//
									// 定位失败提示
									LPToastUtil
											.getInstance()
											.getToast(
													getString(R.string.shop_location_failed),
													BOC_SpecialShop_main_Activity.this);

									// getAroundShopData(isFirst,
									// getUrlBody(true,
									// aroundShopType_S), "");
									// if (layoutFirstSearch.getParent() !=
									// null) {
									// mainLayout
									// .removeView(layoutFirstSearch);
									// if (layoutMostPopShopList.getParent() !=
									// null) {
									// layoutMostPopShopList
									// .setVisibility(View.VISIBLE);
									// } else {
									// mainLayout
									// .addView(layoutMostPopShopList);
									// }
									// pushPageToStack(layoutMostPopShopList,
									// "specialShop");
									// }
									break;
								}
							}

						});
			}
		});

	}

	// 在没有定位进入时想查询路线时先定位
	private void getLocationFirst(final int way_type) {
		runOnUiThread(new Runnable() {
			public void run() {
				locationServices.getLocation(
						BOC_SpecialShop_main_Activity.this, new Handler() {

							@Override
							public void handleMessage(Message msg) {
								switch (msg.what) {
								case 1001:
									if (locationDialog != null
											&& !locationDialog.isShowing())
										locationDialog.show();
									break;
								case 2001:
									locationDialog.dismiss();
									Bundle bundle = msg.getData();
									if (bundle != null) {
										mid.currentLon = bundle
												.getDouble("lon");
										mid.currentLat = bundle
												.getDouble("lat");
										routeInterface(way_type);
										showMapView();
									}
									break;
								case 3001:
									locationDialog.dismiss();

									mid.currentLon = ConfigManager.default_current_lon;
									mid.currentLat = ConfigManager.default_current_lat;
									routeInterface(way_type);
									showMapView();
									break;
								}
							}

						});
			}
		});

	}

	// ========================================================================
	// 定位 end

	// 初始化最红商户首页
	public void instanceFirstSearchView() {
		// MER_CITY_VALUE:aroundShopCity_S,MER_DIST_VALUE:aroundShopDist_S
		// MER_TYPE_VALUE:aroundShopType_S,MER_TYPE_NAME:aroundShopTypeTextVal
		String cityName = PackageManagerAndroid.ANDROIDDB.get(MER_CITY_VALUE);
		String distName = PackageManagerAndroid.ANDROIDDB.get(MER_DIST_VALUE);
		String typeName = PackageManagerAndroid.ANDROIDDB.get(MER_TYPE_NAME);
		String typeValue = PackageManagerAndroid.ANDROIDDB.get(MER_TYPE_VALUE);
		String currentIndex = PackageManagerAndroid.ANDROIDDB
				.get(MER_CURRENT_BIGCITY_INDEX);
		typeNameShow = typeName;
		aroundShopCity_S = cityName;
		aroundShopDist_S = distName;
		aroundShopType_S = typeValue;
		try {
			currentBigIndex = Integer.parseInt(currentIndex);
		} catch (Exception e) {
			currentBigIndex = 0;
		}

		layoutFirstSearch = (LinearLayout) LayoutInflater.from(this).inflate(
				R.layout.special_shop_first_innerlayout, null);
		layoutFirstSearch
				.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
		LinearLayout.LayoutParams parm = (LinearLayout.LayoutParams) layoutFirstSearch
				.getLayoutParams();
		parm.setMargins(15, 15, 15, 15);
		// 获取其它控件
		tvSelectAllShop = (TextView) layoutFirstSearch
				.findViewById(R.id.select_all_shop);
		tvSelectAllShopType = (TextView) layoutFirstSearch
				.findViewById(R.id.select_all_shop_type);
		tvChooseCity = (TextView) layoutFirstSearch
				.findViewById(R.id.tv_choose_city);
		tvChooseCity.setFocusable(true);
		etSearchName = (EditText) layoutFirstSearch
				.findViewById(R.id.et_search_shop);
		BitmapDrawable bd = (BitmapDrawable) this.getResources().getDrawable(
				R.drawable.search_icon_scan);
		etSearchName.setCompoundDrawablesWithIntrinsicBounds(null, null, bd,
				null);
		padLeft = bd.getIntrinsicWidth() + etSearchName.getPaddingLeft();
		etSearchName.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View view, MotionEvent event) {
				float curX = event.getX();
				isNotShowDistChoose = true;
				switch (event.getAction()) {
				case MotionEvent.ACTION_UP:

					if (curX > etSearchName.getWidth() - padLeft) {
						mid.isSB = false;
						aroundShopActTypeText
								.setText(R.string.aroundshop_activity_type);
						sendSearchList(etSearchName.getText().toString(), false);
					}
					break;
				default:
					break;
				}
				return false;
			}
		});
		etSearchName.setImeOptions(EditorInfo.IME_ACTION_GO);
		etSearchName.setOnEditorActionListener(new OnEditorActionListener() {
			@Override
			public boolean onEditorAction(TextView v, int actionId,
					KeyEvent event) {
				mid.isSB = false;
				aroundShopActTypeText
						.setText(R.string.aroundshop_activity_type);
				sendSearchList(etSearchName.getText().toString(), false);
				return true;
			}

		});
		String cityValue = "";
		String cityId = "";
		String saveCity = PackageManagerAndroid.ANDROIDDB.get("city_select");
		if (null != saveCity && !"".equalsIgnoreCase(saveCity)) {
			String[] city = saveCity.split("\\|");
			cityValue = city[1];
			cityId = city[0];
		}

		if (!cityName.equals("")) {
			tvChooseCity.setText(cityName);
		} else {
			if (!cityValue.equals("")) {
				for (int i = 0; i < mid.bigCityClass.length; i++) {
					String cityname = mid.bigCityClass[i];
					if (cityValue.equals(cityname)) {
						tvChooseCity.setText(cityname);
						currentBigIndex = i;
						aroundShopCity_S = cityname;
						break;
					}
				}
			}
		}
		if (!distName.equals("")) {
			tvSelectAllShop.setText(distName);
		}
		if (!typeName.equals("")) {
			tvSelectAllShopType.setText(typeName);
		}

		List<Map<String, Object>> items = new ArrayList<Map<String, Object>>();
		for (int i = 0; i < typename.length; i++) {
			Map<String, Object> item = new HashMap<String, Object>();
			item.put("typename", typename[i]);
			item.put("image", typeImageId[i]);
			items.add(item);

		}

		typeGrid = (GridView) layoutFirstSearch
				.findViewById(R.id.gridViewContext);
		SimpleAdapter adapter = new SimpleAdapter(
				BOC_SpecialShop_main_Activity.this, items,
				R.layout.button_item_hotshop, new String[] { "typename",
						"image" }, new int[] { R.id.button1, R.id.imageView1 });
		typeGrid.setAdapter(adapter);
		typeGrid.setOnItemClickListener(gridListener);

		tvSelectAllShop.setOnClickListener(this);
		tvSelectAllShopType.setOnClickListener(this);
		tvChooseCity.setOnClickListener(this);
	}

	public void sendSearchList(String str, boolean useLocation) {
		hideSoftInput();
		try {
			Thread.sleep(150);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		String urlBody = "";
		String text = "";
		search_name = str;
		if (useLocation) {
			urlBody = "page=1&radius="
					+ Utils.escapeURIComponent(aroundShopRange_S)
					+ "&longitude=" + String.valueOf(currentLon) + "&latitude="
					+ String.valueOf(currentLat) + "&type="
					+ Utils.escapeURIComponent(aroundShopType_S) + "&name="
					+ Utils.escapeURIComponent(str) + "&mark_type="
					+ Utils.escapeURIComponent(mark_Type);
		} else {
			mid.defaultRadiobut = 4;
			urlBody = "page=1&city="
					+ Utils.escapeURIComponent(aroundShopCity_S) + "&dist="
					+ Utils.escapeURIComponent(aroundShopDist_S) + "&type="
					+ Utils.escapeURIComponent(aroundShopType_S) + "&name="
					+ Utils.escapeURIComponent(str) + "&mark_type="
					+ Utils.escapeURIComponent(mark_Type);
		}
		mMapView.getOverlays().clear();
		getAroundShopData(true, urlBody, "");

	}

	private OnItemClickListener gridListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View v, int position,
				long id) {
			Utils.printOutToConsole(position);
			isNotShowDistChoose = false;
			search_name = etSearchName.getText().toString();
			aroundShopActTypeText.setText(R.string.aroundshop_activity_type);
			showRange = "1km";
			mid.isSB = true;
			if (position == 8) {
				BOC_SpecialShop_main_Activity.this
						.runOnUiThread(new Runnable() {

							@Override
							public void run() {
								// 显示滚轮弹出框
								wheelConstant = AROUND_SHOP_TYPE;
								needGetLocation = true;
								initWheelInfo(mid.bigMostPopClass,
										mid.smallMostPopClass,
										mid.bigMostPopMap, mid.smallMostPopMap,
										wheelConstant, "");
								showPopWin();
							}
						});
			} else {
				mid.defaultRadiobut = 1;
				Utils.printOutToConsole(typename[position]);
				typeNameShow = typename[position];
				aroundShopType_S = typeValues[position];
				locationAndQueryData(true, "");
			}
		}
	};
	protected String reply;
	public String textRange;
	private int lastCheck;

	// 初始化最红商户列表页面
	void initMostPopShopList() {
		layoutMostPopShopList = (LinearLayout) LayoutInflater.from(this)
				.inflate(R.layout.specialshop_list_layout, null);
		layoutMostPopShopList.setLayoutParams(new LayoutParams(-1, -1));
		frameList = (FrameLayout) layoutMostPopShopList
				.findViewById(R.id.ix_list);
		// 活动类型
		aroundShopActTypeText = (TextView) layoutMostPopShopList
				.findViewById(R.id.around_shop_activity_type_text);
		aroundShopRegionLinear = (LinearLayout) layoutMostPopShopList
				.findViewById(R.id.shop_region_layout);
		aroundShopRegionLinear.setOnClickListener(this);
		// 范围
		aroundShopRangeText = (TextView) layoutMostPopShopList
				.findViewById(R.id.around_shop_range_text);
		aroundShopRangeLinear = (LinearLayout) layoutMostPopShopList
				.findViewById(R.id.shop_layout_range);
		aroundShopRangeLinear.setOnClickListener(this);

		// 所有分类
		aroundShopTypeText = (TextView) layoutMostPopShopList
				.findViewById(R.id.around_shop_type_text);
		aroundShopTypeLinear = (LinearLayout) layoutMostPopShopList
				.findViewById(R.id.shop_type_layout);
		aroundShopTypeLinear.setOnClickListener(this);

		shopSearchMap = (ImageView) layoutMostPopShopList
				.findViewById(R.id.around_shop_top_map_icon);
		shopSearchMap.setOnClickListener(this);
		shopSearchList = (ImageView) layoutMostPopShopList
				.findViewById(R.id.around_shop_top_list_icon);
		shopSearchList.setOnClickListener(this);
		aroundShopLV = (MyIXListView) layoutMostPopShopList
				.findViewById(R.id.aroundShopLV);
		aroundShopLV.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				AroundShopListObj aroundShopListObj = (AroundShopListObj) parent
						.getAdapter().getItem(position);
				String currPoiLonStr = aroundShopListObj
						.getAroundShopLongitude();
				String currPoiLatStr = aroundShopListObj
						.getAroundShopLatitude();
				if (!currPoiLatStr.equals("")) {
					lat = Double.parseDouble(currPoiLatStr);
					lon = Double.parseDouble(currPoiLonStr);
					gotoDetailView(aroundShopListObj.getAroundShopId(), false);
				}

			}
		});

		// 搜索编辑框
		shopSearchText = (EditText) layoutMostPopShopList
				.findViewById(R.id.shopAroundET);
		noResIV = (TextView) layoutMostPopShopList.findViewById(R.id.noResText);

		// -------初始化地图----------
		app = BankcommApplication.getInstance();
		if (app.mBMapMan == null) {
			app.mBMapMan = new BMapManager(BankcommApplication.getInstance());
			app.mBMapMan.init(app.mStrKey,
					new BankcommApplication.MyGeneralListener());
		}
		app.mBMapMan.start();
		super.initMapActivity(app.mBMapMan);

		mMapView = (MapView) layoutMostPopShopList.findViewById(R.id.bmapView);
		mMapView.setClickable(true);
		// 不显示缩放控件
		mMapView.setBuiltInZoomControls(true);
		// 设置在缩放动画过程中绘制overlay，默认为不绘制。
		mMapView.setDrawOverlayWhenZooming(true);

		mapController = mMapView.getController();
		mapController.setZoom(17);

		mSearch = new MKSearch();
		mSearch.init(app.mBMapMan, mkSearchListener);
		// 初始化POI图标
		myMarker = getResources().getDrawable(R.drawable.baidu_map_me);
		poiMarker = getResources().getDrawable(R.drawable.baidu_map_poi);
		// // 弹出的气泡View
		mPopView = getLayoutInflater().inflate(R.layout.map_pop, null);
		mMapView.addView(mPopView);
		mPopView.setVisibility(View.GONE);
		mPopView.setOnClickListener(popClickListener);
		// 初始化POI集合
		myGeoOverlayItem = new OverItemT(this, poiMarker);
		// mrl=new ShopRequestLocation();
		// tempGeoOverlayItem = new MyPoiOverlayItem(this, poiMarker);
		// ---------------------

		shopSearchText.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View arg0, MotionEvent event) {
				float curX = event.getX();
				isNotShowDistChoose = true;
				switch (event.getAction()) {
				case MotionEvent.ACTION_UP:

					if (curX > etSearchName.getWidth() - padLeft) {
						boolean s = false;
						if (mid.isSB) {
							s = true;
						}
						sendSearchList(shopSearchText.getText().toString(), s);
					}
					break;
				default:
					break;
				}
				return false;
			}
		});
		shopSearchText.setImeOptions(EditorInfo.IME_ACTION_GO);
		shopSearchText.setOnEditorActionListener(new OnEditorActionListener() {
			@Override
			public boolean onEditorAction(TextView v, int actionId,
					KeyEvent event) {
				boolean s = false;
				if (mid.isSB) {
					s = true;
				}
				sendSearchList(shopSearchText.getText().toString(), s);
				return true;
			}

		});
	}

	@Override
	public void onClick(View v) {
		int id = v.getId();
		switch (id) {
		case R.id.select_all_shop:
			// 显示滚轮弹出框
			if (aroundShopCity_S.equals("")) {
				// LPToastUtil.getInstance().getToast("请先选择城市后再进行该操作",
				// BOC_SpecialShop_main_Activity.this);
				handleException("请先选择城市后再进行该操作");
			} else {
				wheelConstant = AROUND_SHOP_CITY;
				// initWheelInfo(mid.bigCityClass, mid.smallCityClass,
				// mid.bigCityMap,
				// mid.smallCityMap, wheelConstant,"big");
				// showPopWin();

				showDistencePicker(mid.smallCityClass[currentBigIndex]);
			}
			break;
		case R.id.select_all_shop_type:
			// 显示滚轮弹出框
			wheelConstant = AROUND_SHOP_TYPE;
			initWheelInfo(mid.bigMostPopClass, mid.smallMostPopClass,
					mid.bigMostPopMap, mid.smallMostPopMap, wheelConstant, "");
			showPopWin();
			break;
		case R.id.tv_choose_city:
			// 显示滚轮弹出框
			wheelConstant = AROUND_SHOP_CITY;
			initWheelInfo(mid.bigCityClass, mid.smallCityClass, mid.bigCityMap,
					mid.smallCityMap, wheelConstant, "small");
			showPopWin();
			break;

		case R.id.shop_region_layout:
			// 特惠商户列表内选活动类型
			showChooseAllTypeDialog();
			break;
		case R.id.shop_type_layout:
			// //特惠商户列表内选类型
			alertChooseType();
			break;
		case R.id.around_shop_top_map_icon:
			hideSoftInput();

			shopSearchList.setVisibility(View.VISIBLE);
			shopSearchMap.setVisibility(View.GONE);

			leftRotate();
			frameList.startAnimation(leftAnimation3d);
			mMapView.startAnimation(rightAnimation3d);

			frameList.setVisibility(View.GONE);
			mMapView.setVisibility(View.VISIBLE);
			mMapView.bringToFront();
			break;
		case R.id.around_shop_top_list_icon:
			hideSoftInput();

			shopSearchList.setVisibility(View.GONE);
			shopSearchMap.setVisibility(View.VISIBLE);

			rightRotate();
			frameList.startAnimation(leftAnimation3d);
			mMapView.startAnimation(rightAnimation3d);

			frameList.setVisibility(View.VISIBLE);

			mMapView.setVisibility(View.GONE);
			frameList.bringToFront();

			break;

		case R.id.shop_layout_range:
			textRange = aroundShopRangeText.getText().toString();
			lastCheck = mid.defaultRadiobut;
			distancePicker.defaultradiobut();
			alertChooseDistance();
			break;

		case R.id.backtitle:
			keybackPressed();
			break;

		case R.id.hometitle:
			BOC_SpecialShop_main_Activity.this.finish();
			break;
		}

	}

	/**
	 * 隐藏键盘
	 */
	private void hideSoftInput() {

		InputMethodManager iim = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		if (iim.isActive() && getCurrentFocus() != null) {
			iim.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
					InputMethodManager.HIDE_NOT_ALWAYS);
		}
	}

	private void alertChooseType() {

		int popheight = height - getStatusBarHeight() - 46
				- aroundShopTypeText.getHeight();
		line.bigTypeAdapter.setSelectedPosition(0);
		line.smallTypeAdapter.bigPostion = 0;
		line.smallTypeAdapter.notifyDataSetChanged();
		line.smallTypeAdapter.notifyDataSetInvalidated();
		aroundPW = new PopupWindow(line, width, popheight, true);
		aroundPW.setBackgroundDrawable(new BitmapDrawable()); // 是否点击窗口外的区域可取消
		aroundPW.setAnimationStyle(android.R.style.Animation_Toast);
		aroundPW.showAsDropDown(aroundShopTypeText);
		aroundPW.update();
	};

	private void alertChooseDistance() {

		int popheight = height - getStatusBarHeight() - 46
				- aroundShopTypeText.getHeight();
		aroundPW = new PopupWindow(distancePicker, width, popheight, true);
		aroundPW.setBackgroundDrawable(new BitmapDrawable()); // 是否点击窗口外的区域可取消
		aroundPW.setAnimationStyle(android.R.style.Animation_Toast);
		aroundPW.showAsDropDown(aroundShopTypeText);
		aroundPW.update();
	};

	private void initWheelInfo(final String[] bigClass,
			final String[][] smallClass, final HashMap<Integer, String> bigMap,
			final HashMap<Integer, HashMap<Integer, String>> smallMap,
			final int wheelConstant, String type) {
		wheelView = LayoutInflater.from(BOC_SpecialShop_main_Activity.this)
				.inflate(R.layout.around_search_wheel, null);

		final WheelView bigClassView = (WheelView) wheelView
				.findViewById(R.id.bigClass);
		bigClassView.setVisibleItems(5);
		bigClassView.setAdapter(new ArrayWheelAdapter<String>(bigClass));

		final WheelView smallClassView = (WheelView) wheelView
				.findViewById(R.id.smallClass);
		smallClassView.setVisibleItems(5);

		// 只有一个滚轮的场景, 范围滚轮
		if (smallClass == null) {
			smallClassView.setVisibility(View.GONE);
		}

		if (!type.equals("")) {
			if (type.equals("small")) {
				smallClassView.setVisibility(View.GONE);
			} else if (type.equals("big")) {
				bigClassView.setVisibility(View.GONE);
			}
		}

		switch (wheelConstant) {
		case AROUND_SHOP_CITY:
			bigClassView.setCurrentItem(currentBigIndex);
			smallClassView.setAdapter(new ArrayWheelAdapter<String>(
					mid.smallCityClass[currentBigIndex]));
			// smallClassView.setCurrentItem(currentBigIndex);

			bigClassView.addChangingListener(new OnWheelChangedListener() {

				@Override
				public void onChanged(WheelView wheel, int oldValue,
						int newValue) {

					currentBigIndex = newValue;

					smallClassView.setAdapter(new ArrayWheelAdapter<String>(
							mid.smallCityClass[newValue]));
					aroundShopCitySmallItem = 0;
					smallClassView.setCurrentItem(aroundShopCitySmallItem);
				}
			});
			// bigClassView.setCurrentItem(aroundShopCityBigItem);
			break;
		case AROUND_SHOP_RANGE:
			// 若未保存范围值时, 默认让滚轮选中默认范围项.
			bigClassView.setCurrentItem(aroundShopRangeItem);
			break;
		case AROUND_SHOP_TYPE:
			smallClassView.setCurrentItem(0);
			bigClassView.addChangingListener(new OnWheelChangedListener() {

				@Override
				public void onChanged(WheelView wheel, int oldValue,
						int newValue) {
					smallClassView.setAdapter(new ArrayWheelAdapter<String>(
							smallClass[newValue]));
					aroundShopCitySmallItem = 0;
					smallClassView.setCurrentItem(aroundShopTypeSmallItem);
				}
			});
			bigClassView.setCurrentItem(aroundShopTypeBigItem);
			break;
		}

		// 确定
		Button sureBtn = (Button) wheelView.findViewById(R.id.sure);
		sureBtn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				final int bigItem = bigClassView.getCurrentItem();
				final int smallItem = smallClassView.getCurrentItem();

				switch (wheelConstant) {

				case AROUND_SHOP_CITY:
					// 设置为不搜索身边, 则表示搜索商圈.
					mid.isSB = false;

					// 改变范围滚轮的值
					// aroundShopRangeText.setText("不限距离");

					aroundShopCityBigItem = bigItem;
					aroundShopCitySmallItem = smallItem;

					// // 城市、商圈
					String aroundShopCity_c = bigClass[bigItem];
					String aroundShopDist_c = "";
					if (aroundShopCity_c != null
							&& getString(R.string.aroundshop_all_region)
									.equals(aroundShopCity_c)) {
						aroundShopCity_c = "";
						aroundShopDist_c = "";
					} else {
						aroundShopDist_c = smallClass[bigItem][smallItem];
					}

					if (aroundShopDist_c != null
							&& getString(R.string.aroundshop_all_dist).equals(
									aroundShopDist_c)) {
						aroundShopDist_c = "";
					}

					// // 显示文本
					String aroundShopCity = "";
					String aroundShopDist = "";
					if (!"".equals(aroundShopDist_c)) {
						// 改为只显示商圈
						aroundShopDist = aroundShopDist_c;
					} else {
						if (!"".equals(aroundShopCity_c)) {
							aroundShopCity = aroundShopCity_c;
						} else {
							aroundShopCity = getString(R.string.aroundshop_all_region);
						}
					}
					// 存储城市、商圈(存本地)
					aroundShopCity_S = aroundShopCity_c;
					aroundShopDist_S = aroundShopDist_c;
					if (aroundShopDist_S.equals("所有")) {
						aroundShopDist_S = "";
					}
					Utils.printOutToConsole(aroundShopCity_S + "     "
							+ aroundShopDist_S);

					PackageManagerAndroid.ANDROIDDB.save(MER_CITY_VALUE,
							aroundShopCity_S);
					PackageManagerAndroid.ANDROIDDB.save(MER_DIST_VALUE,
							aroundShopDist_S);
					PackageManagerAndroid.ANDROIDDB.save(
							MER_CURRENT_BIGCITY_INDEX, String
									.valueOf(currentBigIndex));

					if (!aroundShopCity_S.equals("")) {
						tvChooseCity.setText(aroundShopCity_S);
					} else {
						tvChooseCity.setText("所有地区");
					}
					if (!aroundShopDist_S.equals("")) {
						tvSelectAllShop.setText(aroundShopDist_S);
					} else {
						tvSelectAllShop
								.setText(getText(R.string.merchant_all_dist));
					}

					break;
				case AROUND_SHOP_TYPE:
					aroundShopTypeBigItem = bigItem;
					aroundShopTypeSmallItem = smallItem;

					String aroundShopType_t = "";
					if (bigMap.get(bigItem) != null) {
						aroundShopType_t = bigMap.get(bigItem);
					} else {
						aroundShopType_t = smallMap.get(bigItem).get(smallItem);
					}

					// 显示文本
					String aroundShopTypeTextVal = "";
					if (bigMap.get(bigItem) != null) {
						aroundShopTypeTextVal = bigClass[bigItem];
					} else {
						// 改成只显示小类, 若是所有则显示大类.
						if ("所有".equals(smallClass[bigItem][smallItem])) {
							aroundShopTypeTextVal = bigClass[bigItem];
						} else {
							aroundShopTypeTextVal = smallClass[bigItem][smallItem];
						}
					}
					aroundShopType_S = aroundShopType_t;
					if (!needGetLocation) {
						tvSelectAllShopType.setText(aroundShopTypeTextVal);

						// 存储类型
						Utils.printOutToConsole(aroundShopTypeTextVal + "   "
								+ aroundShopType_S);
						PackageManagerAndroid.ANDROIDDB.save(MER_TYPE_NAME,
								aroundShopTypeTextVal);
						PackageManagerAndroid.ANDROIDDB.save(MER_TYPE_VALUE,
								aroundShopType_S);
					}
					typeNameShow = aroundShopTypeTextVal;
					if (needGetLocation) {
						mid.isSB = true;
						PackageManagerAndroid.ANDROIDDB.save(MER_TYPE_NAME, "");
						PackageManagerAndroid.ANDROIDDB
								.save(MER_TYPE_VALUE, "");

						if (locationDialog != null
								&& !locationDialog.isShowing())
							locationDialog.show();
						mid.defaultRadiobut = 1;
						locationAndQueryData(true, "");
						needGetLocation = false;
						if (aroundPW.isShowing()) {
							aroundPW.dismiss();
						}
						return;
					}

					break;
				}
				if (aroundPW.isShowing()) {
					aroundPW.dismiss();
				}

			}
		});

		// 取消
		Button cancelBtn = (Button) wheelView.findViewById(R.id.cancel);
		cancelBtn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				needGetLocation = false;
				if (aroundPW.isShowing()) {
					aroundPW.dismiss();
				}
			}
		});
	}

	private void showPopWin() {
		aroundPW = new PopupWindow(wheelView, width,
				WindowManager.LayoutParams.WRAP_CONTENT, true);
		aroundPW.setBackgroundDrawable(new BitmapDrawable()); // 是否点击窗口外的区域可取消
		aroundPW.setAnimationStyle(R.style.PopupAnimation);
		int yoff = DensityUtil.dip2px(BOC_SpecialShop_main_Activity.this, 0);
		aroundPW.showAtLocation(mainLayout, Gravity.BOTTOM, 0, yoff);
		aroundPW.update();
	}

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}

	/**
	 * 根据各种参数获取列表信息
	 * 
	 * @param isFirst
	 *            是否首次请求列表数据
	 * @param aroundShopType
	 *            类别信息
	 * @param textVal
	 *            滚轮搜索文本值
	 */
	private void getAroundShopData(final boolean isFirst, final String urlBody,
			final String textVal) {
		mid.waitDialog_.addFgTask(this, null, 0, 0, 0, new WaitDialog.Task(0) {

			@Override
			public void run(WaitDialog dlg) throws Exception {
				// Message getAroundShopM = new Message();
				// getAroundShopM.what = 1;
				// getAroundShopHandler.sendMessage(getAroundShopM);
				Utils.printOutToConsole("url:===" + ConfigManager.SERVER_URI
						+ ConfigManager.MAP_GET_MERCHANT_LIST);
				Utils.printOutToConsole("body:===" + urlBody);

				reply = (String) mid.hm_.sendPostRequest(
						ConfigManager.SERVER_URI
								+ ConfigManager.MAP_GET_MERCHANT_LIST, urlBody,
						this, null, null);
				Utils.printOutToConsole(reply);
			}

			@Override
			public void onSuccess(WaitDialog dlg) {
				Message getAroundShopM = new Message();
				getAroundShopM.what = 2;

				runOnUiThread(new Runnable() {

					@Override
					public void run() {
						shopSearchText.setText(search_name);
						try {
							aroundShopDataObj = archiveAroundShopObj(reply);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						if (isFirst) {
							String aroundShopRange = aroundShopDataObj
									.getRange();
							String[] aroundShopRanges = aroundShopRange
									.split(",");

							String[] distArr = null;
							// 判断选中的是否是所有，不是时候再返回索引
							if (currentBigIndex != 0) {
								distArr = mid.smallCityClass[currentBigIndex];
							} else {
								distArr = null;
							}

							distancePicker = new DistanceAndDistPicker(
									BOC_SpecialShop_main_Activity.this,
									distArr, aroundShopRanges);
						}

						if (mid.isSB) {
							aroundShopRangeText.setText("身边" + showRange);
							// mid.defaultRadiobut=1;
							aroundShopTypeText
									.setText(typeNameShow == "" ? "所有类型"
											: typeNameShow);
						} else {
							String text = "";
							mid.defaultRadiobut = 4;
							if (aroundShopDist_S.equals("")) {
								text = "所有商圈";
							} else {
								text = aroundShopDist_S;
							}
							aroundShopRangeText.setText(text);
							aroundShopTypeText
									.setText(typeNameShow == "" ? "所有类型"
											: typeNameShow);
						}

						if (aroundShopDataObj.getList() != null
								&& aroundShopDataObj.getList().size() > 0) {
							aroundShopLV.setVisibility(View.VISIBLE);
							noResIV.setVisibility(View.GONE);
							// 保存第一個商戶的經緯度, 以備地圖頁面使用
							if (!aroundShopDataObj.getList().get(0)
									.getAroundShopLatitude().equals("")) {
								centerLat = Double.valueOf(aroundShopDataObj
										.getList().get(0)
										.getAroundShopLatitude());
								centerLon = Double.valueOf(aroundShopDataObj
										.getList().get(0)
										.getAroundShopLongitude());
							}
							// 设置下拉刷新是否可用
							aroundShopLV.setPullRefreshEnable(false);

							// 设置上拉加载更多是否可用
							if ("0".equals(aroundShopDataObj.getCurrPage())) {
								aroundShopLV.setPullLoadEnable(false);
							} else {
								aroundShopLV.setPullLoadEnable(true);
							}
							//
							// 改进为如下方式.
							if (isFirst || aroundShopListAdapter == null) {
								aroundShopListAdapter = new AroundShopListAdapter(
										BOC_SpecialShop_main_Activity.this,
										aroundShopLV);
								aroundShopListAdapter.setList(aroundShopDataObj
										.getList());
								aroundShopLV.setAdapter(aroundShopListAdapter);
								aroundShopLV
										.setXListViewListener(BOC_SpecialShop_main_Activity.this);
							} else {
								aroundShopListAdapter.setList(aroundShopDataObj
										.getList());
								aroundShopListAdapter.notifyDataSetChanged();
							}
							//
							// // 地图数据
							// drawPoints(aroundShopDataObj.getList());

							addPoint();
							if (mid.isSB) {
								mapController.setZoom(17);
								showMyLocation(mid.currentLat, mid.currentLon,
										myMarker);
							} else {
								mapController.setZoom(10);
							}
						} else {
							aroundShopLV.setVisibility(View.GONE);
							noResIV.setVisibility(View.VISIBLE);
							if (mid.isSB) {
								showMyLocation(mid.currentLat, mid.currentLon,
										myMarker);
							}
						}
					}
				});

				getAroundShopHandler.sendMessage(getAroundShopM);
				runOnUiThread(new Runnable() {
					public void run() {
						if (layoutFirstSearch.getParent() != null) {
							mainLayout.removeView(layoutFirstSearch);
							if (layoutMostPopShopList.getParent() != null) {
								layoutMostPopShopList
										.setVisibility(View.VISIBLE);
							} else {
								mainLayout.addView(layoutMostPopShopList);
							}
							pushPageToStack(layoutMostPopShopList,
									"specialShop");
						}

					}
				});
				super.onSuccess(dlg);
			}

			@Override
			public void onFailure(WaitDialog dlg) {
				// if (ConfigManager.contiun) {
				getAroundShopPD.dismiss();
				// sessionTimeout(BOC_SpecialShop_main_Activity.this,
				// getErrMsg());
				// } else {
				Message getAroundShopM = new Message();
				getAroundShopM.what = 3;
				getAroundShopM.obj = getErrMsg();
				getAroundShopHandler.sendMessage(getAroundShopM);
				// }
				super.onFailure(dlg);
			}
		});
	}

	Handler getAroundShopHandler = new Handler() {
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				if (getAroundShopPD != null && !getAroundShopPD.isShowing()) {
					getAroundShopPD.show();
				}
				break;
			case 2:
				getAroundShopPD.dismiss();
				break;
			case 3:
				getAroundShopPD.dismiss();
				if (msg.obj != null) {
					handleException(msg.obj.toString());
				}
				break;
			}
		};
	};

	// {
	// "merchantImageUrl" :
	// "http://wap.95559.com.cn/mobilebank/images/merchant/36349104344655da0134784cb69b38e4.PNG",
	// "merchantName" : "天家国金店",
	// "merchantIntro" : "优惠信息：刷卡消费满188元,赠送价值30元咖啡一份,优惠不同享",
	// "merId" : "36349104344655da0134784cb69b38e4",
	// "aroundShopDistance" : "241",
	// "aroundShopName" : "天家国金店",
	// "aroundShopAddress" : "世纪大道8号国金中心4F",
	// "aroundShopMarkType" : "SPECIAL",
	// "aroundShopGrade" : "0",
	// "aroundShopLongitude" : "121.5027",
	// "aroundShopLatitude" : "31.23702"
	// }

	// 处理数据
	public AroundShopObj archiveAroundShopObj(String reply) throws Exception {
		AroundShopObj aroundShopJSONObj = new AroundShopObj();
		JSONObject aroundShopObjJO = new JSONObject(reply);

		// 当前页, 保存以便加载更多使用.
		String currPage = aroundShopObjJO.getString("currPage");
		aroundShopJSONObj.setCurrPage(currPage);
		mid.pm_.autoTextDB_.save("aroundShopCurrPage", currPage);

		// 范围
		if (aroundShopObjJO.has("aroundShopRange")) {
			String aroundShopRange = aroundShopObjJO
					.getString("aroundShopRange");
			aroundShopJSONObj.setRange(aroundShopRange);
		}

		// 列表
		JSONArray aroundShopListJA = aroundShopObjJO
				.getJSONArray("merchantList");
		ArrayList<AroundShopListObj> aroundShopList = new ArrayList<AroundShopListObj>();
		for (int i = 0; i < aroundShopListJA.length(); i++) {
			AroundShopListObj aroundShopListObj = new AroundShopListObj();
			JSONObject aroundShopListJO = (JSONObject) aroundShopListJA.get(i);

			aroundShopListObj.setAroundShopImageUrl(aroundShopListJO
					.getString("merchantImageUrl"));
			aroundShopListObj.setAroundShopName(aroundShopListJO
					.getString("merchantName"));

			// 判断评分是否为空
			String aroundShopGradeStr = aroundShopListJO
					.getString("aroundShopGrade");
			if (aroundShopGradeStr != null && aroundShopGradeStr.length() > 0) {
				aroundShopListObj.setAroundShopGrade(Integer
						.valueOf(aroundShopGradeStr));
			} else {
				aroundShopListObj.setAroundShopGrade(0);
			}

			aroundShopListObj.setAroundShopAddress(aroundShopListJO
					.getString("aroundShopAddress"));
			aroundShopListObj.setAroundShopMarkType(aroundShopListJO
					.getString("aroundShopMarkType"));
			aroundShopListObj.setAroundShopDistance(aroundShopListJO
					.getString("aroundShopDistance"));
			aroundShopListObj.setAroundShopId(aroundShopListJO
					.getString("merId"));
			aroundShopListObj.setAroundShopLongitude(aroundShopListJO
					.getString("aroundShopLongitude"));
			aroundShopListObj.setAroundShopLatitude(aroundShopListJO
					.getString("aroundShopLatitude"));
			aroundShopListObj.setAroundShopTelNo(aroundShopListJO
					.getString("phone"));
			aroundShopList.add(aroundShopListObj);
		}
		aroundShopJSONObj.setList(aroundShopList);
		return aroundShopJSONObj;
	}

	/**
	 * 获取urlBody
	 * 
	 * @param isSB
	 *            是否请求身边, SB意义深远, 记录我此刻心情.
	 * @param currType
	 *            当前类型
	 * @return
	 */
	private String getUrlBody(boolean isSB, String currType) {
		String urlBody = "";
		if (isSB) {
			// 若未保存范围值时
			if (aroundShopRange_S == null || aroundShopRange_S.length() == 0) {
				aroundShopRange_S = DEFAULTRANGE;
			}
			// mid.currentLon = ConfigManager.default_current_lon;
			// mid.currentLat = ConfigManager.default_current_lat;
			urlBody = "page=1&radius="
					+ Utils.escapeURIComponent(aroundShopRange_S)
					+ "&longitude=" + String.valueOf(currentLon) + "&latitude="
					+ String.valueOf(currentLat) + "&type="
					+ Utils.escapeURIComponent(currType) + "&name="
					+ Utils.escapeURIComponent(search_name) + "&mark_type="
					+ Utils.escapeURIComponent(mark_Type);
		} else {
			urlBody = "page=1&city="
					+ Utils.escapeURIComponent(aroundShopCity_S) + "&dist="
					+ Utils.escapeURIComponent(aroundShopDist_S) + "&type="
					+ Utils.escapeURIComponent(currType) + "&name="
					+ Utils.escapeURIComponent(search_name) + "&mark_type="
					+ Utils.escapeURIComponent(mark_Type);
		}
		return urlBody;
	}

	// 上拉加载更多回调方法
	@Override
	public void onLoadMore() {
		ixHandler.postDelayed(new Runnable() {
			@Override
			public void run() {

				mid.waitDialog_.addBgTask(new Task(0) {
					AroundShopObj aroundShopMoreObj;

					@Override
					public void run(WaitDialog dlg) throws Exception {
						// TODO Auto-generated method stub
						String aroundShopCurrPage_ = mid.pm_.autoTextDB_
								.get("aroundShopCurrPage");

						String urlBodyM = "";
						if (mid.isSB) {
							// 若未保存范围值时
							if (aroundShopRange_S == null
									|| aroundShopRange_S.length() == 0) {
								aroundShopRange_S = DEFAULTRANGE;
							}
							urlBodyM = "page="
									+ aroundShopCurrPage_
									+ "&radius="
									+ Utils
											.escapeURIComponent(aroundShopRange_S)
									+ "&longitude="
									+ String.valueOf(currentLon)
									+ "&latitude="
									+ String.valueOf(currentLat)
									+ "&type="
									+ Utils
											.escapeURIComponent(aroundShopType_S)
									+ "&name="
									+ Utils.escapeURIComponent(search_name)
									+ "&mark_type="
									+ Utils.escapeURIComponent(mark_Type);
						} else {
							urlBodyM = "page="
									+ aroundShopCurrPage_
									+ "&city="
									+ Utils
											.escapeURIComponent(aroundShopCity_S)
									+ "&dist="
									+ Utils
											.escapeURIComponent(aroundShopDist_S)
									+ "&type="
									+ Utils
											.escapeURIComponent(aroundShopType_S)
									+ "&name="
									+ Utils.escapeURIComponent(search_name)
									+ "&mark_type="
									+ Utils.escapeURIComponent(mark_Type);
						}

						String reply = (String) mid.hm_.sendPostRequest(
								ConfigManager.SERVER_URI
										+ ConfigManager.MAP_GET_MERCHANT_LIST,
								urlBodyM, null, null, null);
						aroundShopMoreObj = archiveAroundShopObj(reply);
					}

					@Override
					public void onSuccess(WaitDialog dlg) {

						runOnUiThread(new Runnable() {
							public void run() {
								// 若当前页为0, 则不显示"更多"
								if ("0".equals(aroundShopMoreObj.getCurrPage())) {
									aroundShopLV.setPullLoadEnable(false);
								}

								addPoint();
								if (mid.isSB) {
									mapController.setZoom(17);
									showMyLocation(mid.currentLat,
											mid.currentLon, myMarker);
								} else {
									mapController.setZoom(10);
								}
								ArrayList<AroundShopListObj> lists = aroundShopListAdapter
										.getList();
								lists.addAll(aroundShopMoreObj.getList());

								aroundShopListAdapter.setList(lists);
								// addPoint();
								aroundShopListAdapter.notifyDataSetChanged();
								onLoad(aroundShopLV);

							}
						});

						super.onSuccess(dlg);
					}

					@Override
					public void onFailure(WaitDialog dlg) {

						super.onFailure(dlg);
						handleException(getErrMsg());
					}

				});

			}
		}, 2000);
	}

	private void onLoad(MyIXListView ixListView) {
		ixListView.stopRefresh();
		ixListView.stopLoadMore();
		ixListView.setRefreshTime("刚刚");
	}

	@Override
	public void onRefresh() {
		// TODO Auto-generated method stub

	}

	private int getStatusBarHeight() {
		Class<?> c = null;
		Object obj = null;
		Field field = null;
		int statusBarHeight = 0;
		int x = 0;
		try {
			c = Class.forName(Utils.getConfigStringFormAsset(this,
					"cominternal"));
			obj = c.newInstance();
			field = c.getField(Utils.getConfigStringFormAsset(this,
					"statusbarheight"));
			x = Integer.parseInt(field.get(obj).toString());
			statusBarHeight = getResources().getDimensionPixelSize(x);

		} catch (Exception e) {
			Utils.printException(e);
		}
		return statusBarHeight;
	}

	/**
	 * 监听返回键
	 */
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			keybackPressed();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	private void keybackPressed() {
		LPMid.hideInputMethod(this);

		if (branchDetail != null && branchDetail.getVisibility() == View.GONE) {
			runOnUiThread(new Runnable() {
				public void run() {
					layoutMostPopShopList.setVisibility(View.GONE);
					branchDetail.setVisibility(View.VISIBLE);
				}
			});
			return;
		}

		Stack<PageInfo> currStack = pageInfos.get("specialShop");
		if (currStack == null || currStack.size() <= 1) {
			finish();
		} else {
			// 取出上次的报文, 重新加载
			backRefresh(currStack);
		}
	}

	private int mCenterX = 160;
	private int mCenterY = 0;
	private Rotate3d leftAnimation3d;
	private Rotate3d rightAnimation3d;
	private View branchDetail;

	// 左旋转
	public void leftRotate() {
		leftAnimation3d = new Rotate3d(0, -90, 0.0f, 0.0f, mCenterX, mCenterY);
		rightAnimation3d = new Rotate3d(90, 0, 0.0f, 0.0f, mCenterX, mCenterY);
		leftAnimation3d.setFillAfter(true);
		leftAnimation3d.setDuration(1000);
		rightAnimation3d.setFillAfter(true);
		rightAnimation3d.setDuration(1000);
	}

	// 右旋转
	public void rightRotate() {
		leftAnimation3d = new Rotate3d(-90, 0, 0.0f, 0.0f, mCenterX, mCenterY);
		rightAnimation3d = new Rotate3d(0, 90, 0.0f, 0.0f, mCenterX, mCenterY);
		leftAnimation3d.setFillAfter(true);
		leftAnimation3d.setDuration(1000);
		rightAnimation3d.setFillAfter(true);
		rightAnimation3d.setDuration(1000);
	}

	@Override
	protected void onPause() {
		app.mBMapMan.stop();
		super.onPause();
	}

	@Override
	protected void onResume() {
		app.mBMapMan.start();
		super.onResume();
	}

	/**
	 * 调至详情页面
	 * 
	 * @param merIdStr
	 *            商户ID
	 * @param isFromMapToDetail
	 *            是否从地图到详情
	 */
	void gotoDetailView(final String merIdStr, final boolean isFromMapToDetail) {
		mid.waitDialog_.addFgTask(this, null, 0, 0, 0, new WaitDialog.Task(0) {
			String aroundShopDetailRes = null;

			@Override
			public void run(WaitDialog dlg) throws Exception {
				Utils.printOutToConsole(ConfigManager.MAP_GET_MERCHANT_DETAIL);

				// Message getAroundShopM = new Message();
				// getAroundShopM.what = 1;
				// getAroundShopHandler.sendMessage(getAroundShopM);

				String urlBody = "merId=" + merIdStr;
				String url = ConfigManager.SERVER_URI
						+ ConfigManager.MAP_GET_MERCHANT_DETAIL;

				aroundShopDetailRes = (String) mid.hm_.sendPostRequest(url,
						urlBody, this, null, null);
				Utils.printOutToConsole(aroundShopDetailRes);
			}

			@Override
			public void onSuccess(WaitDialog dlg) {
				Message getAroundShopM = new Message();
				getAroundShopM.what = 2;
				getAroundShopHandler.sendMessage(getAroundShopM);
				String locationXY = "";
				locationXY = getMerchantDetailInfo(aroundShopDetailRes,
						locationXY);
				super.onSuccess(dlg);

			}

			@Override
			public void onFailure(WaitDialog dlg) {

				Message getAroundShopM = new Message();
				getAroundShopM.what = 3;
				getAroundShopM.obj = getErrMsg();
				getAroundShopHandler.sendMessage(getAroundShopM);
				super.onFailure(dlg);
			}
		});
	}

	/**
	 * "merchantTitle" : "merchantAddress" "favorableInfo" : "
	 * "merchantIntroduce" "merchantSpecial" : "merchantRegion" :
	 * "merchantTraffic" : merchantParking
	 * **/
	private String getMerchantDetailInfo(String merchantDetailResult,
			String locationXY) {
		try {
			String[] favorableInfoArr = null;
			String[] favorableEndTimeArr = null;

			JSONObject branchResultJO = new JSONObject(merchantDetailResult);

			JSONArray aroundShopImageUrls = branchResultJO
					.getJSONArray("aroundShopImageUrls");

			String[] aroundShopUrl = new String[aroundShopImageUrls.length()];
			final ArrayList<String> list = new ArrayList<String>();
			for (int i = 0; i < aroundShopImageUrls.length(); i++) {
				JSONObject urlObj = aroundShopImageUrls.getJSONObject(i);
				aroundShopUrl[i] = urlObj.getString("aroundShopImageUrl");
				list.add(aroundShopUrl[i]);
			}

			String merchantTitle = Utils.unescapeURIComponent(branchResultJO
					.getString("merchantTitle"));
			String merchantAddress = Utils.unescapeURIComponent(branchResultJO
					.getString("merchantAddress"));
			final String merchantPhone = branchResultJO
					.getString("merchantPhone");
			locationXY = branchResultJO.getString("merchantCoord");

			// 优惠信息(可能会有多条)
			JSONArray infoJA = new JSONArray(branchResultJO.getString("info"));
			if (infoJA.length() > 0) {
				for (int i = 0; i < infoJA.length(); i++) {
					favorableInfoArr = new String[infoJA.length()];
					favorableEndTimeArr = new String[infoJA.length()];

					JSONObject currentInfoJO = (JSONObject) infoJA.get(i);
					favorableInfoArr[i] = Utils
							.unescapeURIComponent(currentInfoJO
									.getString("favorableInfo"));
					favorableEndTimeArr[i] = currentInfoJO
							.getString("favorableEndTime");
				}
			}

			String merchantIntroduce = Utils
					.unescapeURIComponent(branchResultJO
							.getString("merchantIntroduce"));
			String merchantSpecial = Utils.unescapeURIComponent(branchResultJO
					.getString("merchantSpecial"));
			String merchantRegion = Utils.unescapeURIComponent(branchResultJO
					.getString("merchantRegion"));
			String merchantTraffic = Utils.unescapeURIComponent(branchResultJO
					.getString("merchantTraffic"));
			String merchantParking = Utils.unescapeURIComponent(branchResultJO
					.getString("merchantParking"));

			String openTime = branchResultJO.getString("openTime");
			String favorableStartTime = branchResultJO.getString("postDate");

			branchDetail = getLayoutInflater().inflate(
					R.layout.merchant_detail, null);

			branchDetail.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));

			// LOGO
			final MostPopShopGallery merchantLogoImage = (MostPopShopGallery) branchDetail
					.findViewById(R.id.merchantLogoImage);

			BOC_SpecialShop_main_Activity.this.runOnUiThread(new Runnable() {

				@Override
				public void run() {
					merchantLogoImage.initLayout(
							BOC_SpecialShop_main_Activity.this, list);
				}
			});

			// 名称
			TextView merchantTitleText = (TextView) branchDetail
					.findViewById(R.id.merchantTitleText);
			merchantTitleText.setText(merchantTitle);

			// 地址
			TextView merchantAddressText = (TextView) branchDetail
					.findViewById(R.id.merchantAddressText);
			merchantAddressText.setText(getString(R.string.merchant_address)
					+ merchantAddress);
			ImageView merchantAddressImage = (ImageView) branchDetail
					.findViewById(R.id.merchantAddressImage);
			merchantAddressImage.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					mMapView.getOverlays().clear();
					if (lon == 0.0) {
						LPToastUtil.getInstance().getToast(
								BOC_SpecialShop_main_Activity.this
										.getString(R.string.locationError),
								BOC_SpecialShop_main_Activity.this);
					} else {
						showMyLocation(lat, lon, poiMarker);
						showMapView();
					}
				}
			});

			// 驾车路线
			ImageView drivingImage = (ImageView) branchDetail
					.findViewById(R.id.drivingImage);
			drivingImage.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					mMapView.getOverlays().clear();
					if (lon == 0.0) {
						LPToastUtil.getInstance().getToast(
								BOC_SpecialShop_main_Activity.this
										.getString(R.string.locationError),
								BOC_SpecialShop_main_Activity.this);
					} else {
						if (mid.currentLat != 0) {
							routeInterface(WAY_DRIVING);
							showMapView();
						} else {
							getLocationFirst(WAY_DRIVING);
						}
					}
				}
			});

			// 公交路线
			ImageView busImage = (ImageView) branchDetail
					.findViewById(R.id.busImage);
			busImage.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					mMapView.getOverlays().clear();
					if (lon == 0.0) {
						LPToastUtil.getInstance().getToast(
								BOC_SpecialShop_main_Activity.this
										.getString(R.string.locationError),
								BOC_SpecialShop_main_Activity.this);
					} else {
						if (mid.currentLat != 0) {
							routeInterface(WAY_TRANSIT);
							showMapView();
						} else {
							getLocationFirst(WAY_TRANSIT);
						}
					}
				}
			});

			// 步行路线
			ImageView walkingImage = (ImageView) branchDetail
					.findViewById(R.id.walkingImage);
			walkingImage.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					mMapView.getOverlays().clear();
					if (lon == 0.0) {
						LPToastUtil.getInstance().getToast(
								BOC_SpecialShop_main_Activity.this
										.getString(R.string.locationError),
								BOC_SpecialShop_main_Activity.this);
					} else {
						if (mid.currentLat != 0) {
							routeInterface(WAY_WALKING);
							showMapView();
						} else {
							getLocationFirst(WAY_WALKING);
						}
					}
				}
			});

			// 电话
			TextView merchantPhoneText = (TextView) branchDetail
					.findViewById(R.id.merchantPhoneText);
			merchantPhoneText.setText(getString(R.string.merchant_phone)
					+ merchantPhone);

			ImageView callImage = (ImageView) branchDetail
					.findViewById(R.id.callImage);
			callImage
					.setOnClickListener(new android.view.View.OnClickListener() {

						@Override
						public void onClick(View arg0) {
							if (!merchantPhone.equals("")
									&& merchantPhone != null) {
								initDelDialog(merchantPhone);
							}

						}
					});

			// 优惠信息
			if (favorableInfoArr != null) {
				LinearLayout favorableInfosLayout = (LinearLayout) branchDetail
						.findViewById(R.id.favorableInfos);

				for (int i = 0; i < favorableInfoArr.length; i++) {
					String favorableInfo = favorableInfoArr[i];
					String favorableEndTime = favorableEndTimeArr[i];

					LinearLayout layout = new LinearLayout(
							BOC_SpecialShop_main_Activity.this);
					LayoutParams layoutParams = new LayoutParams(
							LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
					// layoutParams.leftMargin = 10;
					// layoutParams.rightMargin = 10;
					layoutParams.bottomMargin = 10;
					layout.setLayoutParams(layoutParams);
					layout.setOrientation(LinearLayout.VERTICAL);

					TextView infoText = new TextView(
							BOC_SpecialShop_main_Activity.this);
					LayoutParams infoLayoutParam = new LayoutParams(
							LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT);
					infoLayoutParam.bottomMargin = 7;
					infoText.setLayoutParams(infoLayoutParam);
					infoText.setText(favorableInfo);
					infoText.setTextColor(Color.rgb(127, 157, 227));
					layout.addView(infoText);

					View view = new View(BOC_SpecialShop_main_Activity.this);
					view
							.setBackgroundResource(R.drawable.horizontal_separation_line);
					view.setLayoutParams(new LayoutParams(
							LayoutParams.FILL_PARENT, 1));
					layout.addView(view);

					TextView timeTextStart = new TextView(
							BOC_SpecialShop_main_Activity.this);
					LayoutParams timeLayoutParam = new LayoutParams(
							LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT);
					timeLayoutParam.topMargin = 7;
					timeTextStart.setLayoutParams(timeLayoutParam);
					timeTextStart
							.setText(getString(R.string.favorable_start_time)
									+ favorableStartTime);
					timeTextStart.setTextColor(Color.rgb(127, 157, 227));
					layout.addView(timeTextStart);

					TextView timeText = new TextView(
							BOC_SpecialShop_main_Activity.this);
					// LayoutParams timeLayoutParam = new LayoutParams(
					// LayoutParams.WRAP_CONTENT,
					// LayoutParams.WRAP_CONTENT);
					// timeLayoutParam.topMargin = 7;
					timeText.setLayoutParams(timeLayoutParam);
					timeText.setText(getString(R.string.favorable_end_time)
							+ favorableEndTime);
					timeText.setTextColor(Color.rgb(127, 157, 227));
					layout.addView(timeText);

					favorableInfosLayout.addView(layout);
				}
			}

			// 商户介绍
			TextView merchantIntroduceText = (TextView) branchDetail
					.findViewById(R.id.merchantIntroduceText);
			merchantIntroduceText.setText(merchantIntroduce);

			// 特色
			TextView merchantSpecialText = (TextView) branchDetail
					.findViewById(R.id.merchantSpecialText);
			merchantSpecialText.setText(merchantSpecial);

			// 地区
			TextView merchantRegionText = (TextView) branchDetail
					.findViewById(R.id.merchantRegionText);
			merchantRegionText.setText(merchantRegion);

			TextView merOpenTimeText = (TextView) branchDetail
					.findViewById(R.id.merchantOpenTimeText);
			merOpenTimeText.setText(openTime);

			// 交通
			TextView merchantTrafficText = (TextView) branchDetail
					.findViewById(R.id.merchantTrafficText);
			merchantTrafficText.setText(merchantTraffic);

			// 停车位
			TextView merchantParkingText = (TextView) branchDetail
					.findViewById(R.id.merchantParkingText);
			merchantParkingText.setText(merchantParking);

			BOC_SpecialShop_main_Activity.this.runOnUiThread(new Runnable() {

				@Override
				public void run() {
					layoutMostPopShopList.setVisibility(View.GONE);
					mainLayout.addView(branchDetail);
					pushPageToStack(branchDetail, "specialShop");
				}
			});

		} catch (JSONException e) {
			e.printStackTrace();
		}
		return locationXY;
	}

	private void routeInterface(int routeConstant) {

		// 将当前页面放置栈

		switch (routeConstant) {
		case WAY_DRIVING:
			myDrivingSearch(lat, lon);
			break;
		case WAY_TRANSIT:
			myTransitSearch(lat, lon);
			break;
		case WAY_WALKING:
			myWalkingSearch(lat, lon);
			break;
		}
	}

	private void myDrivingSearch(double endLat, double endLon) {
		MKPlanNode start = new MKPlanNode();
		// start.pt = new GeoPoint((int) (mid.currentLat * 1e6),
		// (int) (mid.currentLon * 1e6));
		start.pt = offsetLocation(mid.currentLon, mid.currentLat);
		MKPlanNode end = new MKPlanNode();
		// end.pt = new GeoPoint((int) (endLat * 1e6), (int) (endLon * 1e6));
		end.pt = offsetLocation(endLon, endLat);
		// 设置驾车路线搜索策略, 时间优先、 费用最少或距离最短
		mSearch.setDrivingPolicy(MKSearch.ECAR_TIME_FIRST);
		mSearch.drivingSearch(null, start, null, end);
	}

	private void myTransitSearch(double endLat, double endLon) {
		MKPlanNode start = new MKPlanNode();
		// start.pt = new GeoPoint((int) (mid.currentLat * 1e6),
		// (int) (mid.currentLon * 1e6));
		start.pt = offsetLocation(mid.currentLon, mid.currentLat);
		MKPlanNode end = new MKPlanNode();
		end.pt = offsetLocation(endLon, endLat);
		// end.pt = new GeoPoint((int) (endLat * 1e6), (int) (endLon * 1e6));
		// 设置乘车路线搜索策略, 时间优先、最少换乘、 最少步行距离或不含地铁
		mSearch.setTransitPolicy(MKSearch.EBUS_TIME_FIRST);
		mSearch.transitSearch("上海", start, end); // 必须设置城市名
	}

	private void myWalkingSearch(double endLat, double endLon) {
		MKPlanNode start = new MKPlanNode();
		// start.pt = new GeoPoint((int) (mid.currentLat * 1e6),
		// (int) (mid.currentLon * 1e6));
		start.pt = offsetLocation(mid.currentLon, mid.currentLat);
		MKPlanNode end = new MKPlanNode();
		end.pt = offsetLocation(endLon, endLat);
		// end.pt = new GeoPoint((int) (endLat * 1e6), (int) (endLon * 1e6));
		// 设置驾车路线搜索策略, 时间优先, 费用最少或距离最短
		mSearch.setDrivingPolicy(MKSearch.ECAR_TIME_FIRST);
		mSearch.walkingSearch(null, start, null, end);
	}

	// 搜索事件监听
	private MKSearchListener mkSearchListener = new MKSearchListener() {

		@Override
		public void onGetDrivingRouteResult(MKDrivingRouteResult res, int iError) {
			Message m = new Message();
			m.what = 2001;

			if (iError != 0 || res == null) {
				LPToastUtil.getInstance().getToast("抱歉，未找到结果",
						BOC_SpecialShop_main_Activity.this);
				return;
			}

			RouteOverlay routeOverlay = new RouteOverlay(
					BOC_SpecialShop_main_Activity.this, mMapView);
			routeOverlay.setData(res.getPlan(0).getRoute(0));
			mMapView.getOverlays().clear();
			mMapView.getOverlays().add(routeOverlay);
			mMapView.invalidate();
			mMapView.getController().animateTo(res.getStart().pt);

		}

		@Override
		public void onGetTransitRouteResult(MKTransitRouteResult res, int iError) {
			Message m = new Message();
			m.what = 2001;

			if (iError != 0 || res == null) {
				LPToastUtil.getInstance().getToast("抱歉，未找到结果",
						BOC_SpecialShop_main_Activity.this);
				return;
			}
			TransitOverlay routeOverlay = new TransitOverlay(
					BOC_SpecialShop_main_Activity.this, mMapView);
			// 此处仅展示一个方案作为示例
			routeOverlay.setData(res.getPlan(0));
			mMapView.getOverlays().clear();
			mMapView.getOverlays().add(routeOverlay);
			mMapView.invalidate();
			mMapView.getController().animateTo(res.getStart().pt);

		}

		@Override
		public void onGetWalkingRouteResult(MKWalkingRouteResult res, int iError) {
			Message m = new Message();
			m.what = 2001;

			if (iError != 0 || res == null) {
				LPToastUtil.getInstance().getToast("抱歉，未找到结果",
						BOC_SpecialShop_main_Activity.this);
				return;
			}
			RouteOverlay routeOverlay = new RouteOverlay(
					BOC_SpecialShop_main_Activity.this, mMapView);
			// 此处仅展示一个方案作为示例
			routeOverlay.setData(res.getPlan(0).getRoute(0));
			mMapView.getOverlays().clear();
			mMapView.getOverlays().add(routeOverlay);
			mMapView.invalidate();
			mMapView.getController().animateTo(res.getStart().pt);

		}

		@Override
		public void onGetAddrResult(MKAddrInfo res, int iError) {

		}

		@Override
		public void onGetPoiResult(MKPoiResult res, int type, int iError) {

		}

		@Override
		public void onGetBusDetailResult(MKBusLineResult arg0, int arg1) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onGetPoiDetailSearchResult(int arg0, int arg1) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onGetRGCShareUrlResult(String arg0, int arg1) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onGetSuggestionResult(MKSuggestionResult arg0, int arg1) {
			// TODO Auto-generated method stub

		}
	};

	private void clearPageStack() {
		pageInfos.get("specialShop").clear();
	}

	private void pushPageToStack(View currView, String channelName) {
		PageInfo newPage = new PageInfo();
		List<View> views = new ArrayList<View>();
		views.add(currView);
		newPage.setComponents(views);
		newPage.setLeftSideVisible(true);
		newPage.setRightSideVisible(true);
		newPage.setBackInfo(null);
		pageInfos.get(channelName).push(newPage);
	}

	/**
	 * <pre>
	 * 返回到上一个页面
	 * currStack 当前栈
	 * </pre>
	 */
	public void backRefresh(final Stack<PageInfo> currStack) {
		if (currStack != null && currStack.size() > 1) {
			LPMid.getInstance().waitDialog_.addFgTask(this, null, 0, 0, 0,
					new WaitDialog.Task(0) {
						// 返回的报文数据串
						PageInfo lastPage = null;

						@Override
						public void run(WaitDialog dlg) throws Exception {

							// Message getAroundShopM = new Message();
							// getAroundShopM.what = 1;
							// getAroundShopHandler.sendMessage(getAroundShopM);
							currStack.pop();
							if (currStack.size() < 1) {
								lastPage = null;
							} else {
								lastPage = (PageInfo) currStack.peek();
							}
						}

						@Override
						public void onSuccess(WaitDialog dlg) {
							Message getAroundShopM = new Message();
							getAroundShopM.what = 2;
							getAroundShopHandler.sendMessage(getAroundShopM);

							if (lastPage == null) {
								finish();
							} else {
								// 放至主线程
								BOC_SpecialShop_main_Activity.this
										.runOnUiThread(new Runnable() {
											@Override
											public void run() {
												try {
													for (View singView : lastPage
															.getComponents()) {
														if (singView == layoutMostPopShopList) {
															mainLayout
																	.removeView(branchDetail);
															layoutMostPopShopList
																	.setVisibility(View.VISIBLE);
														} else if (singView == layoutFirstSearch) {

															cleanState();
															layoutMostPopShopList
																	.setVisibility(View.GONE);
															// instanceFirstSearchView();
															// mainLayout.addView(layoutFirstSearch);
															mainLayout
																	.addView(singView);
															String cityName = PackageManagerAndroid.ANDROIDDB
																	.get(MER_CITY_VALUE);
															String distName = PackageManagerAndroid.ANDROIDDB
																	.get(MER_DIST_VALUE);
															String typeName = PackageManagerAndroid.ANDROIDDB
																	.get(MER_TYPE_NAME);
															String typeValue = PackageManagerAndroid.ANDROIDDB
																	.get(MER_TYPE_VALUE);
															String currentIndex = PackageManagerAndroid.ANDROIDDB
																	.get(MER_CURRENT_BIGCITY_INDEX);
															typeNameShow = typeName;
															aroundShopCity_S = cityName;
															aroundShopDist_S = distName;
															aroundShopType_S = typeValue;
															etSearchName
																	.setText("");
															if (!cityName
																	.equals("")) {
																tvChooseCity
																		.setText(cityName);
															}
															if (!distName
																	.equals("")) {
																tvSelectAllShop
																		.setText(distName);
															}
															if (!typeName
																	.equals("")) {
																tvSelectAllShopType
																		.setText(typeName);
															}
															try {
																currentBigIndex = Integer
																		.parseInt(currentIndex);
															} catch (Exception e) {
																currentBigIndex = 0;
															}
														}
													}
												} catch (Exception e) {
													e.printStackTrace();
												}
											}
										});
							}

							super.onSuccess(dlg);
						}

						@Override
						public void onFailure(WaitDialog dlg) {
							Message getAroundShopM = new Message();
							getAroundShopM.what = 3;
							getAroundShopM.obj = getErrMsg();
							getAroundShopHandler.sendMessage(getAroundShopM);
							super.onFailure(dlg);
						}
					});
		}
	}

	@Override
	public void finish() {
		super.finish();
		BankcommApplication.getInstance().mHandler = null;
		BankcommApplication.getInstance().removeActivity(this);
	}

	public void showMyLocation(double excursionCurrLat,
			double excursionCurrLon, Drawable marker) {
		GeoPoint myGeoPoint = offsetLocation(excursionCurrLon, excursionCurrLat);
		mMapView.getController().setCenter(myGeoPoint);

		OverlayItem item = new OverlayItem(myGeoPoint, "", "");
		List<OverlayItem> items = new ArrayList<OverlayItem>();
		items.add(item);

		MyLocationOverlayItem myOI = new MyLocationOverlayItem(
				BOC_SpecialShop_main_Activity.this, marker, items);
		List<Overlay> overlays = mMapView.getOverlays();
		// overlays.clear();
		overlays.add(myOI);
	}

	private View.OnClickListener popClickListener = new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			mPopView.setVisibility(View.GONE);
			String id = mMerchantIDList.get(currentID);
			for (int i = 0; i < pointList.size(); i++) {
				if (currentID == i) {
					HashMap<String, Double> Map = pointList.get(i);
					lat = Map.get("lat");
					lon = Map.get("lon");
				}
			}
			// String currPoiLonStr = mMerchantIDList.getAroundShopLongitude();
			// String currPoiLatStr = mMerchantIDList.getAroundShopLatitude();
			// lat = Double.parseDouble(currPoiLatStr);
			// lon = Double.parseDouble(currPoiLonStr);
			gotoDetailView(id, false);
		}
	};
	public String showRange;

	class OverItemT extends ItemizedOverlay<OverlayItem> {

		public ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
		public BOC_SpecialShop_main_Activity mActivity;
		public Drawable marker;

		public OverItemT(BOC_SpecialShop_main_Activity activity, Drawable marker) {
			super(boundCenterBottom(marker));
			this.mActivity = activity;
			this.marker = marker;
		}

		@Override
		public void draw(Canvas canvas, MapView mapView, boolean shadow) {
			super.draw(canvas, mapView, shadow);
			// 调整一个drawable边界，使得（0，0）是这个drawable底部最后一行中心的一个像素
			boundCenterBottom(marker);
		}

		public void addOverlay(OverlayItem overlay) {
			mOverlays.add(overlay);
			populate();
		}

		@Override
		protected OverlayItem createItem(int i) {
			return mOverlays.get(i);
		}

		@Override
		public int size() {
			return mOverlays.size();
		}

		// 处理当点击事件
		@Override
		protected boolean onTap(int i) {
			currentID = i;
			OverlayItem currOI = mOverlays.get(i);
			View currPopView = this.mActivity.mPopView;

			// 名称
			TextView titleText = (TextView) currPopView
					.findViewById(R.id.pop_title);
			titleText.setText(currOI.getTitle());

			// 地址
			String snippet = currOI.getSnippet();
			String[] snippetArr = snippet.split("\\|");

			String messageText = null;
			// 多网点
			if (snippetArr.length > 1) {
				messageText = snippetArr[snippetArr.length - 2];
				LPMid.getInstance().currentBranchBody = snippetArr[snippetArr.length - 1];
			}
			// 单网点
			else {
				messageText = snippetArr[0];
			}
			TextView addressText = (TextView) currPopView
					.findViewById(R.id.pop_address);
			addressText.setText(messageText);

			setFocus(currOI);
			GeoPoint pt = currOI.getPoint();
			int latit = pt.getLatitudeE6();
			int longi = pt.getLongitudeE6();
			// lat=latit << 6;
			// lon=longi << 6;

			MapView.LayoutParams params = new MapView.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, pt,
					MapView.LayoutParams.BOTTOM_CENTER);
			this.mActivity.mMapView.updateViewLayout(currPopView, params);
			// 移动至中心
			this.mActivity.mMapView.getController().animateTo(pt);

			int xoff = DensityUtil.dip2px(mActivity, 1.2f);
			int yoff = DensityUtil.dip2px(mActivity, 30f);
			params.x -= xoff;
			params.y -= yoff;

			currPopView.setVisibility(View.VISIBLE);
			// **重要**，否则popView会被地图给遮盖
			currPopView.bringToFront();
			return true;
		}

		// 消去弹出的气泡
		@Override
		public boolean onTap(GeoPoint p, MapView mapView) {
			this.mActivity.mPopView.setVisibility(View.GONE);
			return super.onTap(p, mapView);
		}

	}

	/***
	 * 
	 * 
	 * */
	private void addPoint() {
		try {
			mMerchantIDList.clear();
			mMapView.getOverlays().clear();
			myGeoOverlayItem.mOverlays.clear();
			for (int i = 0; i < aroundShopDataObj.getList().size(); i++) {

				AroundShopListObj currASList = aroundShopDataObj.getList().get(
						i);
				String currPoiLatStr = currASList.getAroundShopLatitude();
				String currPoiLonStr = currASList.getAroundShopLongitude();
				String currMerChantId = currASList.getAroundShopId();
				double currPoiLatp = Double.parseDouble(currPoiLatStr);
				double currPoiLonp = Double.parseDouble(currPoiLonStr);
				HashMap<String, Double> pointMap = new HashMap<String, Double>();
				pointMap.put("lat", currPoiLatp);
				pointMap.put("lon", currPoiLonp);
				pointList.add(pointMap);

				GeoPoint currentPoint = new GeoPoint((int) (currPoiLatp * 1e6),
						(int) (currPoiLonp * 1e6));
				GeoPoint baiduPoint = CoordinateConvert
						.bundleDecode(CoordinateConvert
								.fromGcjToBaidu(currentPoint));

				mMapView.getController().setCenter(baiduPoint);
				OverlayItem item = new OverlayItem(baiduPoint, currASList
						.getAroundShopName().toString(), currASList
						.getAroundShopAddress());
				myGeoOverlayItem.addOverlay(item);
				mMerchantIDList.add(currMerChantId);
			}
			mMapView.getOverlays().add(myGeoOverlayItem);
			mMapView.invalidate();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * 使用api偏移
	 * 
	 * @param currentLon
	 * @param currentLat
	 * @return GeoPoint
	 */
	public GeoPoint offsetLocation(double currentLon, double currentLat) {
		GeoPoint currentPoint = new GeoPoint((int) (currentLat * 1e6),
				(int) (currentLon * 1e6));
		return CoordinateConvert.bundleDecode(CoordinateConvert
				.fromGcjToBaidu(currentPoint));
	}

	public void showMapView() {
		layoutMostPopShopList.setVisibility(View.VISIBLE);
		branchDetail.setVisibility(View.GONE);

		shopSearchList.setVisibility(View.VISIBLE);
		shopSearchMap.setVisibility(View.GONE);

		leftRotate();
		frameList.startAnimation(leftAnimation3d);
		mMapView.startAnimation(rightAnimation3d);

		frameList.setVisibility(View.GONE);
		mMapView.setVisibility(View.VISIBLE);
		mMapView.bringToFront();
	}

	public void showMakeSureChooseCity(String oldCity, final String newCity) {
		String notice = "";
		if (!oldCity.equals("所有地区") && !oldCity.equals("选择城市")
				&& !oldCity.equals("")) {
			notice = "您当前选择的城市是" + oldCity + ",如需使用附近功能,请切换城市为" + newCity
					+ ",是否切换城市？";
		} else {
			notice = "您当前未选择城市,如需使用附近功能,请切换城市为" + newCity + ",是否切换城市？";
		}
		final Builder ad = new AlertDialog.Builder(
				BOC_SpecialShop_main_Activity.this);
		ad.setTitle("提示").setMessage(notice).setCancelable(false)
				.setNegativeButton("否", new DialogInterface.OnClickListener() {

					public void onClick(DialogInterface dialog, int which) {
						mid.isSB = false;
						PageInfo lastPage = null;
						Stack<PageInfo> currStack = pageInfos
								.get("specialShop");
						if (currStack.size() < 1) {
							lastPage = null;
						} else {
							lastPage = (PageInfo) currStack.peek();
						}
						for (View singView : lastPage.getComponents()) {
							if (singView == layoutMostPopShopList) {
								aroundShopRangeText.setText(textRange);
								mid.defaultRadiobut = lastCheck;

							}
							if (singView == layoutFirstSearch) {
								typeNameShow = tvSelectAllShopType.getText()
										.toString();
							}
						}
					}
				}).setPositiveButton("是",
						new DialogInterface.OnClickListener() {

							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								aroundShopCitySmallItem = 0;
								Utils.printOutToConsole("========"
										+ currentBigIndex);
								PackageManagerAndroid.ANDROIDDB.save(
										MER_CURRENT_BIGCITY_INDEX, String
												.valueOf(currentBigIndex));
								PageInfo lastPage = null;
								Stack<PageInfo> currStack = pageInfos
										.get("specialShop");
								if (currStack.size() < 1) {
									lastPage = null;
								} else {
									lastPage = (PageInfo) currStack.peek();
								}
								for (View singView : lastPage.getComponents()) {
									if (singView == layoutMostPopShopList) {
										aroundShopCity_S = currentCity;
										if (distancePicker != null) {

											distancePicker.boderGrid
													.setAdapter(new DistenceAdaper(
															BOC_SpecialShop_main_Activity.this,
															mid.smallCityClass[currentBigIndex]));
											distancePicker.boderGrid
													.setVisibility(View.VISIBLE);
										}
										PackageManagerAndroid.ANDROIDDB.save(
												MER_CITY_VALUE, newCity);
										PackageManagerAndroid.ANDROIDDB.save(
												MER_DIST_VALUE, "");
										getAroundShopData(true, getUrlBody(
												true, aroundShopType_S), "");
										aroundShopDist_S = "";

										return;
									}
								}
								cleanState();
								PackageManagerAndroid.ANDROIDDB.save(
										MER_CITY_VALUE, newCity);
								tvChooseCity.setText(newCity);
								PackageManagerAndroid.ANDROIDDB.save(
										MER_DIST_VALUE, "");
								aroundShopCity_S = newCity;
								tvSelectAllShop.setText("所有商圈");

								int index = mid.defaultRadiobut;
								if (index == 4) {
									aroundShopRangeText.setText("所有商圈");
								} else {
									aroundShopRangeText.setText("身边"
											+ showRange);
								}

							}
						});
		ad.show();
	}

	/**
	 *<item>特别优惠</item> <item>返刷卡金</item> <item>其他活动</item>
	 **/
	public void showChooseAllTypeDialog() {

		dropDownList = (LinearLayout) LayoutInflater.from(this).inflate(
				R.layout.dropdowntypelist_layout, null);
		ListView dropList = (ListView) dropDownList
				.findViewById(R.id.list_dropdownlist);
		dropList.setAdapter(new ArrayAdapter<String>(this,
				R.layout.drop_list_item, arrayTypeName));

		dropList.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				mark_Type = arrayTypeValue[position];
				aroundShopActTypeText.setText(arrayTypeName[position]);
				String searchName = shopSearchText.getText().toString();
				if (mid.isSB) {
					sendSearchList(searchName, true);
				} else {
					sendSearchList(searchName, false);
				}
				aroundPW.dismiss();
			}
		});

		int popheight = height - getStatusBarHeight() - 46
				- aroundShopTypeText.getHeight();
		aroundPW = new PopupWindow(dropDownList, width, popheight, true);
		aroundPW.setBackgroundDrawable(new BitmapDrawable()); // 是否点击窗口外的区域可取消
		aroundPW.setAnimationStyle(android.R.style.Animation_Toast);
		aroundPW.showAsDropDown(aroundShopTypeText);
		aroundPW.update();
	}

	public void cleanState() {
		mid.isSB = false;
		aroundShopRange_S = "";
		mark_Type = "";
		aroundShopCity_S = "";
		aroundShopDist_S = "";
		aroundShopType_S = "";
		search_name = "";
	}

	public void needLocation() {
		runOnUiThread(new Runnable() {
			public void run() {
				locationServices.getLocation(
						BOC_SpecialShop_main_Activity.this, new Handler() {
							@Override
							public void handleMessage(Message msg) {
								switch (msg.what) {
								case 1001:
									if (locationDialog != null
											&& !locationDialog.isShowing())
										locationDialog.show();
									break;
								case 2001:
									locationDialog.dismiss();
									Bundle bundle = msg.getData();
									if (bundle != null) {
										mid.currentLon = bundle
												.getDouble("lon");
										mid.currentLat = bundle
												.getDouble("lat");

										currentLon = mid.currentLon;
										currentLat = mid.currentLat;
										currentCity = bundle.getString("city");
										Utils
												.printOutToConsole("-=============="
														+ currentCity);
										if (!currentCity.equals("")
												|| currentCity != null) {
											String noCity = "";

											for (int i = 0; i < mid.bigCityClass.length; i++) {
												String cityName = mid.bigCityClass[i];

												if (currentCity
														.equals(cityName)) {
													currentBigIndex = i;
													noCity = "true";

													if (!cityName
															.equals(aroundShopCity_S)
															&& !aroundShopCity_S
																	.equals("选择城市")) {
														try {
															showMakeSureChooseCity(
																	aroundShopCity_S,
																	cityName);

														} catch (Exception e) {
														}

														return;
													}
													int index = mid.defaultRadiobut;
													if (index == 4) {
														aroundShopRangeText
																.setText("所有商圈");
													} else {
														aroundShopRangeText
																.setText("身边"
																		+ showRange);
													}
													getAroundShopData(
															true,
															getUrlBody(true,
																	aroundShopType_S),
															"");
													break;
												}
											}
											if (noCity.equals("")) {
												LPToastUtil
														.getInstance()
														.getToast(
																"对不起,您所在的城市暂无最红商户!",
																BOC_SpecialShop_main_Activity.this);
												return;
											}

										} else {
											return;
										}
										//										

									}
									break;
								case 3001:
									locationDialog.dismiss();

									mid.currentLon = ConfigManager.default_current_lon;
									mid.currentLat = ConfigManager.default_current_lat;

									currentCity = "上海";
									if (!currentCity.equals("")
											|| currentCity != null) {
										String noCity = "";

										for (int i = 0; i < mid.bigCityClass.length; i++) {
											String cityName = mid.bigCityClass[i];

											if (currentCity.equals(cityName)) {
												currentBigIndex = i;
												noCity = "true";
												String selectCity = tvChooseCity
														.getText().toString();

												if (!cityName
														.equals(selectCity)
														&& !selectCity
																.equals("选择城市")) {
													showMakeSureChooseCity(
															selectCity,
															cityName);
													return;
												}
												getAroundShopData(
														true,
														getUrlBody(true,
																aroundShopType_S),
														"");
												break;
											}
										}
										if (noCity.equals("")) {
											LPToastUtil
													.getInstance()
													.getToast(
															" 对不起,您所在的城市暂无最红商户!",
															BOC_SpecialShop_main_Activity.this);
											if (aroundPW.isShowing()) {
												aroundPW.dismiss();
											}
											return;
										}
									} else {
										return;
									}
									currentLat = ConfigManager.default_current_lat;
									currentLon = ConfigManager.default_current_lon;
									//
									// 定位失败提示
									LPToastUtil
											.getInstance()
											.getToast(
													getString(R.string.shop_location_failed),
													BOC_SpecialShop_main_Activity.this);
									if (aroundPW.isShowing()) {
										aroundPW.dismiss();
									}
									break;
								}
							}

						});
			}
		});
	}

	private void showDistencePicker(String[] smallType) {
		RelativeLayout showView = (RelativeLayout) LayoutInflater.from(
				BOC_SpecialShop_main_Activity.this).inflate(
				R.layout.bcm_distancepicker, null);
		showView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				aroundPW.dismiss();
			}
		});

		MyBoderGridView grid = (MyBoderGridView) showView
				.findViewById(R.id.areaselect);
		grid.setAdapter(new DistenceAdaper(BOC_SpecialShop_main_Activity.this,
				smallType));
		// #D1FFFFFF
		grid.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// 设置为不搜索身边, 则表示搜索商圈.
				mid.isSB = false;
				aroundShopCitySmallItem = arg2;

				// // 城市、商圈
				String aroundShopCity_c = mid.bigCityClass[currentBigIndex];
				String aroundShopDist_c = "";
				if (aroundShopCity_c != null
						&& getString(R.string.aroundshop_all_region).equals(
								aroundShopCity_c)) {
					aroundShopCity_c = "";
					aroundShopDist_c = "";
				} else {
					aroundShopDist_c = mid.smallCityClass[currentBigIndex][arg2];
				}

				if (aroundShopDist_c != null
						&& getString(R.string.aroundshop_all_dist).equals(
								aroundShopDist_c)) {
					aroundShopDist_c = "";
				}

				// // 显示文本
				String aroundShopCity = "";
				String aroundShopDist = "";
				if (!"".equals(aroundShopDist_c)) {
					// 改为只显示商圈
					aroundShopDist = aroundShopDist_c;
				} else {
					if (!"".equals(aroundShopCity_c)) {
						aroundShopCity = aroundShopCity_c;
					} else {
						aroundShopCity = getString(R.string.aroundshop_all_region);
					}
				}
				// 存储城市、商圈(存本地)
				aroundShopCity_S = aroundShopCity_c;
				aroundShopDist_S = aroundShopDist_c;
				if (aroundShopDist_S.equals("所有")) {
					aroundShopDist_S = "";
				}
				Utils.printOutToConsole(aroundShopCity_S + "     "
						+ aroundShopDist_S);

				PackageManagerAndroid.ANDROIDDB.save(MER_CITY_VALUE,
						aroundShopCity_S);
				PackageManagerAndroid.ANDROIDDB.save(MER_DIST_VALUE,
						aroundShopDist_S);
				PackageManagerAndroid.ANDROIDDB.save(MER_CURRENT_BIGCITY_INDEX,
						String.valueOf(currentBigIndex));

				if (!aroundShopCity_S.equals("")) {
					tvChooseCity.setText(aroundShopCity_S);
				} else {
					tvChooseCity.setText("所有地区");
				}
				if (!aroundShopDist_S.equals("")) {
					tvSelectAllShop.setText(aroundShopDist_S);
				} else {
					tvSelectAllShop
							.setText(getText(R.string.merchant_all_dist));
				}

				aroundPW.dismiss();
			}
		});
		aroundPW = new PopupWindow(showView, width,
				WindowManager.LayoutParams.WRAP_CONTENT, true);
		aroundPW.setBackgroundDrawable(new BitmapDrawable()); // 是否点击窗口外的区域可取消
		aroundPW.setAnimationStyle(android.R.style.Animation_Toast);
		int yoff = DensityUtil.dip2px(BOC_SpecialShop_main_Activity.this, 0);
		aroundPW.showAtLocation(mainLayout, Gravity.BOTTOM, 0, yoff);
		aroundPW.update();
	}

}
